package com.iflytek.utils;

import org.apache.commons.pool2.impl.GenericObjectPoolConfig;
import redis.clients.jedis.Jedis;
import redis.clients.jedis.JedisPool;

public class JedisUtils {

    static JedisPool jedisPool = null;
    static{

        GenericObjectPoolConfig genericObjectPoolConfig = new GenericObjectPoolConfig();
        // 连接池的一些设置就可以放在这里了
        // 配置参数
        genericObjectPoolConfig.setMaxIdle(10); // 最大空闲连接
        genericObjectPoolConfig.setMaxTotal(20); // 最大连接总数
        genericObjectPoolConfig.setMinIdle(5); // 最小空闲连接
        jedisPool = new JedisPool(genericObjectPoolConfig, "hadoop102");
    }

    public static  Jedis getJedis(){

        Jedis jedis = jedisPool.getResource();
        jedis.auth("123456");
        return jedis;
    }
}